//
//  SXStatusForwardCell.swift
//  微博09项目
//
//  Created by mac on 15/9/12.
//  Copyright © 2015年 itcast. All rights reserved.
//

import UIKit

class SXStatusForwardCell: SXStatusCell {
    override var statusViewModel:SXStatusViewModel?{
        didSet{
            //设置转发微博的内容和作者
            forwardLabel.text = statusViewModel?.forWardText
        }
    }
    
     override func setUpUI() {
        super.setUpUI()
        //添加控件
        contentView.insertSubview(backButton, belowSubview: pictureView)
        contentView.insertSubview(forwardLabel, aboveSubview: backButton)
       
       // forwardLabel.backgroundColor = UIColor.redColor()
       
        //设置自动布局
       backButton.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: contentLabel, size: nil, offset: CGPoint(x: -SXStatusCellMargin, y: SXStatusCellMargin))
        
        backButton.ff_AlignVertical(type: ff_AlignType.TopRight, referView: bottomView, size: nil)
       //设置底部布局
        forwardLabel.ff_AlignInner(type: ff_AlignType.TopLeft, referView: backButton, size: nil)
        //设置图片布局
        
       let cons = pictureView.ff_AlignVertical(type: ff_AlignType.BottomLeft, referView: forwardLabel, size:CGSize(width: SXStatusPictureMaxWidth, height: SXStatusPictureItemWidth),offset:CGPoint(x: 0, y: SXStatusCellMargin))

        /// 获得图片约束的宽高
        pictureViewWidthCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Width)
        pictureViewHeightCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Height)
        pictureViewTopCons = pictureView.ff_Constraint(cons, attribute: NSLayoutAttribute.Top)
        
    }
    //懒加载控件
    private lazy var backButton:UIButton = {
        let button = UIButton()
        button.backgroundColor = UIColor(white: 0.9, alpha: 1.0)
        return button
    }()
    //加载
    private lazy var forwardLabel:UILabel = UILabel(title: "发微博那个", color: UIColor.darkGrayColor(), fontSize: 14, layoutWidth: UIScreen.mainScreen().bounds.width - 2 * SXStatusCellMargin)
}
